from flask import Flask
from flask import render_template


app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello Flask!'

@app.route('/work/')
@app.route('/work/<name>')
def hello(name=None):
    arr = ['java','python','c']
    return render_template('work.html', name=name,arr=arr)


from flask import request


@app.route('/login', methods=['POST', 'GET'])
def login():
    err = ""
    if request.method == 'POST':
        name = request.form['name']
        pwd  = request.form['pwd']
        print("name = %s ,pwd =%s" %(name,pwd))
        if name == 'yang' and pwd == '123':
            return "login succ"
        else:
            err = "fail"
    
    return render_template("login.html",err=err)
    

from flask import make_response

@app.route('/ch')
def change_header():
    resp = make_response('<h2>hello</h2>')
    resp.headers['X-Something'] = 'A value'
    return resp


if __name__ == '__main__':
    app.run(host='0.0.0.0',debug=True)